package com.lehe.util;

import java.text.SimpleDateFormat;
import java.text.Format;
import java.text.ParseException;
import java.util.Calendar;
import java.util.Date;

public class DateUtil {
	public static String addDay(String str) {
		try {
			SimpleDateFormat f = new SimpleDateFormat("yyyy-MM-dd");

			Date today = f.parse(str);
			System.out.println("查询日期是:" + f.format(today));

			Calendar c = Calendar.getInstance();
			c.setTime(today);
			c.add(Calendar.DAY_OF_MONTH, 1);// 今天+1天

			Date tomorrow = c.getTime();
			System.out.println("查询日期下一天是:" + f.format(tomorrow));
			return f.format(tomorrow);
		} catch (ParseException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return str;
	}
	
	public static Boolean isToday(String str) {
		try {
			SimpleDateFormat f = new SimpleDateFormat("yyyy-MM-dd");

			Date sday = f.parse(str);
			System.out.println("查询日期是:" + f.format(sday));
			String sdayStr = f.format(sday);
			
			Date today = new Date();
			String todayStr = f.format(today);
			System.out.println("今天是:" + todayStr);
			return todayStr.equals(sdayStr);
		} catch (ParseException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return false;
	}

	public static void main(String[] args) {

		System.out.println(isToday("2018-4-13"));

	}
}
